#include "stock10.h"
#include "stock00.h"
#include "stock20.h"
#include <iostream>

static void useStock0(void)
{
    Stock fluffy_the_cat;

    fluffy_the_cat.aquire("NanoSmart", 20, 12.50);
    fluffy_the_cat.show();
    fluffy_the_cat.buy(15, 18.125);
    fluffy_the_cat.show();
    fluffy_the_cat.sell(400, 20.00);
    fluffy_the_cat.show();
    fluffy_the_cat.buy(300000, 40.125);
    fluffy_the_cat.show();
    fluffy_the_cat.sell(300000, 0.125);
    fluffy_the_cat.show();
}

static void useStock10(void)
{
    using std::cout;
    cout << "Using constructors to create new objects\n";
    Stock10 stock1("NanoSmart", 12, 20.0);
    stock1.show();
    Stock10 stock2 = Stock10("Boffo Objects", 2, 2.0);
    stock2.show();

    cout << "Assigning stock1 to stock2:\n";
    stock2 = stock1;
    cout << "Listing stock1 and stock2:\n";
    stock1.show();
    stock2.show();

    cout << "Using a constructor to reset an object\n";
    stock1 = Stock10("Nifty Foodd", 10, 50.0);
    cout << "Revised stock1:\n";
    stock1.show();
    cout << "Done\n";
}



static void useStock20(void)
{
    const int STKS = 4;

    Stock20 stocks[STKS] =
    {
        Stock20("NanoSmart", 12, 20.0),
        Stock20("Baffo Objectes", 200, 2.0),
        Stock20("Monolithic Objlisks", 130, 3.25),
        Stock20("Fleep Enterprises", 60, 6.5)
    };

    std::cout << "Stock holding:\n";
    int st;
    for (st = 0; st < STKS; st++)
        stocks[st].show();

    const Stock20* top = &stocks[0];

    for (st = 1; st < STKS; st++)
        top = &top->topval(stocks[st]);

    std::cout << "\n Most valuable holding:\n";
    top->show();


}

void stockTest(void)
{
    useStock20();
}

